package extractor;

import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;

import javax.jms.JMSException;
import javax.naming.NamingException;

import messaging.PublisherGateway;

public class SendStatus {

	public static void main(String[] args) throws InterruptedException {
		String jmsConnectionFactory = "ConnectionFactory";
		String jmsTopic = "topic1";
		try {
			PublisherGateway gateway = new PublisherGateway(jmsConnectionFactory, jmsTopic);
			
			for(int i=0; i<10; i++){
				Thread.sleep(2000);
				Timestamp time = new Timestamp((new Date()).getTime());
				HashMap<String, String> map = new HashMap<String, String>();
				Double usage =  0.01 + ((double)i*100)/10000;
				map.put("usage", usage.toString());
				map.put("num", "2");
				StatusData data = new StatusData("cpu", time, map);
				gateway.publish(data);
			}		
		} catch (NamingException | JMSException e) {
			e.printStackTrace();
		}
	}

}
